import sys
sys.path.append(r'.\pyqt_component_library-master\bubble_message')

from bubble_message import BubbleMessage, ChatWidget, MessageType, Notice
from PyQt5.QtWidgets import QLabel, QWidget, QVBoxLayout

class MsgWindow(ChatWidget):
    def __init__(self):
        super().__init__()
        self.BubbleBlocklayout = QVBoxLayout()
        # self.w1 = ChatWidget()
        self.send_avatar = './data/head1.svg'
        self.receive_avatar = './data/head1.jpg'
        self.TEXT = MessageType.Text
        self.IMAGE = MessageType.Image

    def addTextBubble(self,addMsg,is_send = False):
        if is_send:
            bubble_message = BubbleMessage(addMsg, self.send_avatar, Type=self.TEXT, is_send = is_send)
        else:
            bubble_message = BubbleMessage(addMsg, self.receive_avatar, Type=self.TEXT, is_send = is_send)
        self.add_message_item(bubble_message)

    def receiveAppendText(self,appendMsg):
        bubble_message = BubbleMessage(appendMsg, self.receive_avatar, Type=self.TEXT, is_send=False)
        self.add_message_item(bubble_message)

    def sendAppendText(self,appendMsg):
        bubble_message = BubbleMessage(appendMsg, self.send_avatar, Type=self.TEXT, is_send=True)
        self.add_message_item(bubble_message)

    def appendChunk(self,Chunk):
        self.layout0.itemAt(self.LayoutItemCount).MessageAppend(Chunk)
